import request from '@/router/axios';

export const list = (data) => request({
    url: '/task/list',
    method: 'post',
    data
}).then(data => {
    if (data.rows) {
        data.rows.forEach(row => {
            row.Price = row.Price / 100;
            row.MinPrice = row.MinPrice / 100;
            row.Area = row.Area ? row.Area.split(/\s*[;；]\s*/ig) : []
        });
    }
    return data;
});
export const create = (data) => request({
    url: '/task/create',
    method: "post",
    data
});
export const update = (data) => request({
    url: '/task/update',
    method: "post",
    data
});
export const remove = (Id) => request({
    url: '/task/delete',
    method: "post",
    data: {
        Id
    }
});

export function queryKeywordsList(taskId) {
    return request({
        url: '/task/keywords-list',
        method: "get",
        params: {
            id: taskId
        }
    })
}

export function queryPublishList(taskId) {
    return request({
        url: '/task/task-publish-list',
        method: 'get',
        params: {
            id: taskId
        }
    })
}

export function publishTask(ids) {
    return request({
        url: '/task/publish-task',
        method: "post",
        data: {
            Id: ids
        }
    })
}

export function offlineTask(taskId) {
    return request({
        url: '/task/offline-task',
        method: "post",
        data: {
            Id: taskId
        }
    })
}
